<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自定义复选框</title>
    <link rel="stylesheet" href="../public.css">
    <style>
        .box {
            width: 80%;
            margin: 20px auto;
            padding: 20px;
            text-align: center;
            background-color: #f2f2f2;
        }

        input[type='checkbox'] {
            position: absolute;
            clip: rect(0, 0, 0, 0);
        }

        input[type='checkbox']+label::before {
            content: '\a0';
            display: inline-block;
            vertical-align: .1em;
            width: .8em;
            height: .8em;
            margin-right: .2em;
            border-radius: .2em;
            background: silver;
            text-indent: .15em;
            line-height: .65;
        }

        .back input[type='checkbox']:checked+label::before {
            content: '\2713';
            background: yellowgreen;
        }

        .back1 input[type='checkbox']:focus+label::before {
            box-shadow: 0 0 .5em red;
        }

        .back2 input[type='checkbox']:disabled+label::before {
            background: gray;
            box-shadow: none;
            color: #555;
        }

        .back3 input[type='checkbox']+label {
            display: inline-block;
            padding: .3em .5em;
            background: #ccc;
            background-image: linear-gradient(#ddd, #bbb);
            border: 1px solid rgba(0, 0, 0, .2);
            border-radius: .3em;
            box-shadow: 0 1px white inset;
            text-align: center;
            text-shadow: 0 1px 1px white;
        }

        .back3 input[type="checkbox"]:checked+label,
        .back3 input[type="checkbox"]:active+label {
            box-shadow: .05em .1em .2em rgba(0, 0, 0, .6) inset;
            border-color: rgba(0, 0, 0, .3);
            background: #bbb;
        }
    </style>
</head>

<body>
    <div class="content">
        <h1>自定义复选框</h1>
        <ul>
            <li>用css3提供的伪类:checked,这个伪类只在复选框被勾选时才会匹配，不论这个勾选状态是用户交互触发，还是脚本触发</li>
            <li>&lt;label>元素于复选框关联后，也可以起到触发开关的作用</li>
        </ul>
        <div class="box back">
            <input type="checkbox" id="awesome" />
            <label for="awesome">awesome</label>
        </div>
        <div class="box back1">
            <input type="checkbox" id="awesom" />
            <label for="awesom">awesome</label>
        </div>
        <div class="box back2">
            <input type="checkbox" id="aweso" />
            <label for="aweso">awesome</label>
        </div>
        <div class="box back3">
            <input type="checkbox" id="aweso" />
            <label for="aweso">awesome</label>
        </div>
    </div>
</body>

</html>